import * as echarts from 'echarts'
export function echarts1(data) {
  return {
    tooltip: {
      trigger: "item",
      formatter: "{a} <br/>{b}: {c} ({d}%)",
    },
    color: ['#1779d5','#3cd9d3','#5ba1ed'],
    legend: {
      orient: "vertical", 
      x: "right", 
      left: "70%",
      bottom: "30%",
      itemWidth: 15,
      itemHeight: 15,
      textStyle: {
        color: "#00dcfa",
        fontSize: 14,
      },
      formatter: function (name) {
        let target;
        let all = data.reduce((pre, cur) => {
          return pre + cur.value
        },0)
        for (var i = 0, l = data.length; i < l; i++) {
          if (data[i].name == name) {
            target = ((data[i].value / all) * 100).toFixed(0);
          }
        }
        return `${name}  ${target}%`;
      }
    },
    series: [
      {
        name: "访问来源",
        type: "pie",
        selectedMode: "single",
        radius: ["20%", "70%"],
        center: ["45%", "50%"],

        label: {
          position: "inner",
          fontSize: "14",
          fontWeight: "bold",
          color: "#fff",
        },
        labelLine: {
          show: false,
        },
        data: data,
      }
    ],
  }
}
export function echarts2(data) {
  return {
    tooltip: {
      trigger: "axis",
    },
    grid: {
      left: "5%",
      right: "5%",
      bottom: "5%",
      top: "5%",
      containLabel: true,
    },
    xAxis: {
      type: "category",
      data: data.x,
      axisTick: {
        show: false,
      },
      axisLine: {
        //y轴
        show: false,
      },
      axisLabel: {
        color: "#fff",
      },
      splitLine: { show: false }, //去除网格线
    },
    yAxis: {
      type: "value",
      axisTick: {
        show: false,
      },
      axisLine: {
        //y轴
        show: false,
      },
      axisLabel: {
        color: "#fff",
      },
      splitLine: {
        lineStyle: {
          color: ["rgba(255,255,255,0.3)"],
          width: 1,
        },
      },
    },
    series: [
      {
        name: "养殖业",
        type: "line",
        stack: "总量",
        data: data.y,
        itemStyle: {
          normal: {
            color: "#66ddff",
            lineStyle: {
              color: "#66ddff",
            },
          },
        },
      },
    ],
  };

}
export function echarts3(date,data) {
  return {
    tooltip: {
      trigger: "axis",
    },
    grid: {
      left: "5%",
      right: "5%",
      bottom: "0%",
      top: "15%",
      containLabel: true,
    },
    color: ['#b63051','#c08460','#36c1d4'],
    legend: {
      // 距离底部距离设置
      right: "10%",
      top: "0%",
      //小图标宽度设置
      itemWidth: 15,
      itemHeight: 15,
      //图例组件文字样式
      textStyle: {
        color: "rgb(255,255,255,1)"
      }
    },
    xAxis: {
      type: "category",
      axisTick: {
        show: false,
      },
      splitLine: {
        show: false,
      },
      axisLabel: {
        color: "#fff",
      },
      axisLine: {
        lineStyle: {
          color: "#0258b4",
          width: 1, //这里是为了突出显示加上的
        },
      },
      boundaryGap: false,
      data: date,
      splitLine: { show: false }, //去除网格线
    },
    yAxis: {
      show: true,
      type: "value",
      axisTick: {
        show: false,
      },
      splitLine: {
        show: false,
      },
      axisLine: {
        lineStyle: {
          color: "#0258b4",
          width: 1, //这里是为了突出显示加上的
        },
      },
      axisLabel: {
        color: "#fff",
      },
    },
    series: data
  }
}
export function echarts4(data) {
  
  return {
    tooltip: {
      trigger: "axis",
    },
    
    grid: {
      left: "5%",
      right: "5%",
      bottom: "5%",
      top: "5%",
      containLabel: true,
    },
    xAxis: {
      type: "category",
      axisTick: {
        show: false,
      },
      splitLine: {
        show: false,
      },
      axisLabel: {
        color: "#fff",
      },
      axisLine: {
        lineStyle: {
          color: "#0258b4",
          width: 1, //这里是为了突出显示加上的
        },
      },
      boundaryGap: false,
      data: data.x,
      splitLine: { show: false }, //去除网格线
    },
    yAxis: {
      show: true,
      type: "value",
      axisTick: {
        show: false,
      },
      splitLine: {
        show: false,
      },
      axisLine: {
        lineStyle: {
          color: "#0258b4",
          width: 1, //这里是为了突出显示加上的
        },
      },
      axisLabel: {
        color: "#fff",
      },
    },
    series: [
      {
        name: "企业",
        type: "line",
        data: data.y,
        itemStyle: {
          normal: {
            color: "#b63051",
            lineStyle: {
              color: "#b63051",
            },
          },
        },
      }
    ],
  };

}
export function echarts5(data) {

  return {
    tooltip: {
      trigger: "axis",
      axisPointer: {
        type: "shadow",
      },
    },
    axisLabel: {
      color: "#fff",
      fontSize: "12",
    },
    grid: {
      top: "20%",
      left: "5%",
      right: "5%",
      bottom: "5%",
      containLabel: true,
    },
    toolbox: {
      show: true,
      orient: "vertical",
      left: "right",
      top: "center",
    },
    xAxis: [
      {
        type: "category",
        axisTick: { show: false },
        data: data.x,
      },
    ],
    yAxis: [
      {
        type: "value",
        axisLine: {
          show: false,
        },
        splitLine: {
          lineStyle: {
            color: "rgba(255,255,255,.1)",
            width: 2,
          },
        },
      },
    ],
    series: [
      {
        type: "bar",
        label: {},
        emphasis: {
          focus: "series",
        },
        data: data.y,
        itemStyle: {
          normal: {
            color: new echarts.graphic.LinearGradient(
              0,
              1,
              0,
              0,
              [
                {
                  offset: 0,
                  color: "#41c4f9", // 0% 处的颜色
                },
                {
                  offset: 0.4,
                  color: "#7cacf6", // 60% 处的颜色
                },
                {
                  offset: 1,
                  color: "#fe77ef", // 100% 处的颜色
                },
              ],
              false
            ),
            barBorderRadius: 0,
          },
        },
        barWidth: 15,
      },
    ],
  };

}
export function echarts6(data) {
  return {
    tooltip: {
      trigger: "axis",
      axisPointer: {
        // 坐标轴指示器，坐标轴触发有效
        type: "shadow", // 默认为直线，可选为：'line' | 'shadow'
      },
    },
    grid: {
      left: "5%",
      right: "5%",
      bottom: "5%",
      top: "5%",
      containLabel: true,
    },
    axisLabel: {
      color: "#fff",
      fontSize: "12",
    },
    xAxis: [
      {
        type: "category",
        data: data.x,
        axisTick: {
          alignWithLabel: true,
        },
      },
    ],
    yAxis: [
      {
        type: "value",
        axisLabel: {
          color: "#fff",
          fontSize: "12",
        },
        axisLine: {
          show: false,
        },
        splitLine: {
          lineStyle: {
            color: "rgba(255,255,255,.1)",
            width: 2,
          },
        },
      },
    ],
    series: [
      {
        name: "拥有农机数",
        type: "bar",
        barWidth: "60%",
        data: data.y,
        itemStyle: {
          normal: {
            color: new echarts.graphic.LinearGradient(
              0,
              1,
              0,
              0,
              [
                {
                  offset: 0,
                  color: "#3cb8f9", // 0% 处的颜色
                },
                {
                  offset: 0.4,
                  color: "#55c2fb", // 60% 处的颜色
                },
                {
                  offset: 1,
                  color: "#77cffe", // 100% 处的颜色
                },
              ],
              false
            ),
            barBorderRadius: 4,
          },
        },
        barWidth: "26%",
      },
    ],
  };

}